package com.ruoyi.business.mapper.wecom;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.business.domain.vo.UserChatGroupStatisticVO;
import com.ruoyi.business.domain.vo.wecom.admin.RecentActiveCustomerFollowerVO;
import com.ruoyi.business.domain.vo.wecom.admin.RecentActiveCustomerVO;
import com.ruoyi.business.domain.vo.wecom.admin.RecentActiveGroupVO;
import com.ruoyi.business.domain.vo.wecom.admin.TbWecomMsgArchiveVO;
import com.ruoyi.business.domain.wecom.TbWecomMsgArchive;
import com.ruoyi.common.core.domain.PageQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 企业微信会话存档表 Mapper 接口
 * </p>
 *
 * @author
 * @since 2023-XX-XX
 */
@Mapper
public interface TbWecomMsgArchiveMapper extends BaseMapper<TbWecomMsgArchive> {

    /**
     * 查询符合条件的ID总数
     */
    Long selectIdCount(@Param("fromUserId") String fromUserId,
                       @Param("toUserId") String toUserId,
                       @Param("chatId") String chatId,
                       @Param("beginTime") Long beginTime,
                       @Param("endTime") Long endTime);

    /**
     * 分页查询ID列表
     */
    List<Long> selectPageIdList(@Param("offset") Long offset,
                                @Param("size") Long size,
                                @Param("fromUserId") String fromUserId,
                                @Param("toUserId") String toUserId,
                                @Param("chatId") String chatId,
                                @Param("beginTime") Long beginTime,
                                @Param("endTime") Long endTime);

    /**
     * 根据ID列表查询完整数据
     */
    List<TbWecomMsgArchiveVO> selectByIds(@Param("ids") List<Long> ids,
                                          @Param("fromUserId") String fromUserId);


    IPage<RecentActiveGroupVO> sysRecentActiveGroups(
        IPage<RecentActiveGroupVO> page,
        @Param("chatName") String chatName,
        @Param("externalUserid") String externalUserid,
        @Param("beginTime") Long beginTime,
        @Param("endTime") Long endTime
    );


    IPage<RecentActiveCustomerVO> sysRecentActiveCustomers(
        IPage<RecentActiveCustomerVO> page,
        @Param("name") String name,
        @Param("beginTime") Long beginTime,
        @Param("endTime") Long endTime
    );


    IPage<RecentActiveCustomerFollowerVO> selectRecentServicesByCustomerId(IPage<RecentActiveCustomerFollowerVO> page,
                                                                           @Param("name") String name,
                                                                           @Param("externalUserid") String externalUserid,
                                                                           @Param("beginTime") Long beginTime,
                                                                           @Param("endTime") Long endTime
    );


    IPage<UserChatGroupStatisticVO> selectCustomerGroupActiveStatsPage(
        IPage<UserChatGroupStatisticVO> page,
        @Param("externalUserid") String externalUserid,
        @Param("startTime") Long startTime,
        @Param("endTime") Long endTime);


}
